package com.emep.changzhi.analyse.entity.systeminfo;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
* @author Wangcc
* @Description: 用户表
* @date 2018/2/23 11:56
* @version V1.0
*
*/

@Data
@Entity
@Table(name = "sys_user_info")
public class SysUserInfo implements Serializable {

    private static final long serialVersionUID = 7481474811573739883L;


    @Id
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @GeneratedValue(generator = "system-uuid")
    private String  id;

    @Column(name = "user_name",columnDefinition="varchar(100) COMMENT '用户名'")
    private String userName;

    @Column(name = "phone",columnDefinition="varchar(100) COMMENT '手机号'")
    private String phone;

    private String password;

    @Column(name = "is_delete",columnDefinition="varchar(100) COMMENT '用户是否被删除'")
     private String isDelete = "0";

    @Column(name = "create_date",columnDefinition="varchar(100) COMMENT '信息录入时间'")
    private String createDate =  String.valueOf(System.currentTimeMillis());

    /**
     * @ManyToMany注释表示Teacher是多对多关系的一端。
     * @JoinTable描述了多对多关系的数据表关系。name属性指定中间表名称，joinColumns定义中间表与Teacher表的外键关系。
     中间表Teacher_Student的Teacher_ID列是Teacher表的主键列对应的外键列，inverseJoinColumns属性定义了中间表与另外一端(Student)的外键关系。
     */
    @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
    @JoinTable(name = "user_role",
            joinColumns = { @JoinColumn(name = "user_id") },
            inverseJoinColumns = {@JoinColumn(name = "role_id") })
    private Set<SysRoleInfo> sysRoleInfos = new HashSet<SysRoleInfo>(0);


    public SysUserInfo() {
    }



}
